<template>
	<view class="container">
		<view class="list">
			<view class="list_item">
				<view class="left">
					柜子编号
				</view>
				<view class="right">
					<text>{{code}}</text>
				</view>
			</view>
			<view class="list_item">
				<view class="left">
					硬件状态
				</view>
				<view class="right">
					<text>{{state_text}}</text>
					<image src="/static/img/detail/right.png" mode="widthFix"></image>
				</view>
			</view>
			<view class="list_item">
				<view class="left">
					上线时间
				</view>
				<view class="right">
					<text>{{online_time_date}}</text>
				</view>
			</view>
			<view class="list_item">
				<view class="left">
					总收入
				</view>
				<view class="right">
					<text>{{all_income}}</text>
				</view>
			</view>
			<view class="list_item">
				<view class="left">
					帮助电话
				</view>
				<view class="right">
					<text>{{help_phone}}</text>
					<image src="/static/img/detail/right.png" mode="widthFix"></image>
				</view>
			</view>
		</view>

		<view class="list">
			<view class="list_item" @click="editAdd">
				<view class="left">
					地址
				</view>
				<view class="right">
					<text>{{address}}</text>
					<image src="/static/img/detail/right.png" mode="widthFix"></image>
				</view>
			</view>
			<view class="list_item" @click="account">
				<view class="left">
					分账
				</view>
				<view class="right">
					<image src="/static/img/detail/right.png" mode="widthFix"></image>
				</view>
			</view>
		</view>

		<view class="bottom">
			<!-- <view class="bottom" v-if="list.length !==0"> -->
			<view class="tit">
				<text>电池名</text>
				<text>状态</text>
				<text>当前状态</text>
				<text>人次</text>
				<text class="last">时间/分</text>
			</view>

			<view class="content" v-for="(item,index) in list" :key='index'>
				<text>{{item.item_code}}</text>
				<text v-if="item.item_state == 1" class="on-line">{{item.item_state_text}}</text>
				<text v-if="item.item_state == 0" class="off-line">{{item.item_state_text}}</text>
				<text v-if="item.use_state==1" class="off-line">{{item.curr_state_text}}</text>
				<text v-if="item.use_state==0" class="on-line">{{item.curr_state_text}}</text>
				<text>{{item.num}}</text>
				<text>{{item.time_len}}</text>
			</view>

		</view>


	</view>
</template>

<script>
	import {
		batteryDetail
	} from '../../../api/api.js'
	export default {
		data() {
			return {
				device_id: '',
				code: '',
				state_text: '',
				online_time_date: '',
				all_income: '',
				help_phone: '',
				address: '',
				list: [{
						name: '电池1',
						status: 1,
						current: 0,
						people: 10,
						duration: 2561
					},
					{
						name: '电池1',
						status: 1,
						current: 0,
						people: 10,
						duration: 2561
					},
					{
						name: '电池1',
						status: 1,
						current: 1,
						people: 10,
						duration: 2561
					}
				]
			}
		},
		onLoad(options) {
			this.device_id = options.id
			this.getInfo()
		},
		methods: {
			getInfo() {
				batteryDetail({
					device_id: this.device_id
				}).then(res => {
					console.log(res)
					this.code = res.data.code
					this.all_income = res.data.all_income
					this.address = res.data.address
					this.help_phone = res.data.help_phone
					this.state_text = res.data.state_text
					this.online_time_date = res.data.online_time_date
					this.list = res.data.list
				})
			},
			editAdd() {
				uni.navigateTo({
					url: '/pages/agent/index/address'
				})
			},
			account(){
				uni.navigateTo({
					url:'/pages/agent/index/account'
				})
			}
		},
	}
</script>

<style scoped lang="scss">
	.container {
		width: 100%;
		height: 100%;
		background-color: #f6f6f6;
	}

	.list {
		width: 100%;
		background-color: #FFFFFF;
		margin-bottom: 20upx;

		.list_item {
			width: calc(100% - 60upx);
			height: 100upx;
			margin: 0 auto;
			border-bottom: 1upx solid #e9e6e9;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.left {
				text {
					font-size: 24upx;
					color: #999;
				}
			}

			.right {
				display: flex;
				align-items: center;

				text {
					font-size: 28upx;
					color: #999999;
				}

				image {
					width: 15upx;
					margin-left: 10upx;
				}
			}

			.img {
				image {
					width: 40upx;
				}
			}
		}

	}

	.bottom {
		width: calc(100% - 60upx);
		min-height: 300upx;
		padding: 0 30upx;
		background-color: #FFFFFF;

		.tit {
			padding: 30upx 0;
			display: flex;
			align-items: center;
			justify-content: space-between;

			text {
				width: 20%;
				// padding: 0 26upx;
				text-align: center;
				// border-right: 2upx solid #c1c1c1;
			}

			.last {
				border: 0;
			}

		}

		.content {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 10upx;


			text {
				width: 20%;
				color: #999999;
				padding: 0 15upx;
				text-align: center;
			}

			.on-line {
				color: #3bdbbe;
			}

			.off-line {
				color: #ffb6b3;
			}

		}



	}
</style>
